package com.imooc.spark

import org.apache.spark.sql.SparkSession

object DatasetApp {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder().appName("DatasetApp").master("local[2]").getOrCreate()

    //解析csv文件
    val csvDF = spark.read.option("header","true").option("inferSchema","true").csv("")

    import spark.implicits._
    val ds = csvDF.as[Sales]   //需要导入隐式转换

    ds.map(line => line.itemId).show()
    spark.stop()
  }

  case class Sales(transactionId:Int, sustomerId:Int, itemId:Int, amountPaid:Double)
}
